import HttpClient from '../commons/http-client';
import {resetForgetForm, updateForgetForm} from '../reducers/forget-form';

export function submit(form) {
  return async dispatch => {
    const params = {
      verify: form.captcha,
      password: form.newPassword,
    };
    const resetRep = await HttpClient.post('/web/reset', params);
    // console.log(JSON.stringify(resetRep));
    dispatch(resetForgetForm());
  };
}

export function sendCaptcha(email) {
  return async () => {
    const captchaRep = await HttpClient.post('/web/forget', {email});
  };
}

export function update(form) {
  return dispatch => {
    dispatch(updateForgetForm(form));
  };
}
